package com.sutuijingling.a;

import android.graphics.Point;
import android.graphics.Rect;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ScrollView;
import android.widget.TextView;
import com.android.uiautomator.core.UiCollection;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.google.gson.f;
import com.sutuijingling.bean.AccountBean;
import com.sutuijingling.bean.SearchBean;
import com.sutuijingling.bean.g;
import com.sutuijingling.result.d;
import com.sutuijingling.result.v;
import com.sutuijingling.utils.NumberUtil;
import com.sutuijingling.utils.a;
import com.sutuijingling.utils.b;
import com.sutuijingling.utils.c;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import org.apache.http.HttpStatus;

public class e {
    static int NOT_EXIST = HttpStatus.SC_NOT_FOUND;
    static String canBackUpPath = "/data/data/jp.jun_nama.test.utf7ime/files/backup.txt";
    private static final int cosShape = 2;
    protected static boolean isScrollTest = true;
    private static final int miShape1 = 16;
    private static final int miShape2 = 32;
    private static final int ovalShape1 = 4;
    private static final int ovalShape2 = 8;
    static Random rand = new Random();
    private static final int sShape1 = 64;
    private static final int sinShape = 1;
    private static final int yuanShape = 128;
    protected AccountBean accParams;
    protected Point[] backwardPoints;
    protected d commentParams;
    int defaultScrollTime = 5;
    protected UiDevice device;
    protected Point[] forwardPoints;
    protected long missionId;
    protected SearchBean searchParams;

    public e(UiDevice uiDevice) {
        this.device = uiDevice;
    }

    private boolean changeAction() throws UiObjectNotFoundException {
        UiObject findText = findText("更换", 2);
        if (!findText.exists()) {
            return false;
        }
        c.c(findText);
        c.c();
        c.c(findText);
        c.c();
        c.c(findText("写入", 2));
        c.e();
        return true;
    }

    private void checkTaoJinBi() {
        checkTitleBar("淘金币");
    }

    private void checkTaoQiangGou() {
        checkTitleBar("淘抢购");
    }

    private void checkTitleBar(String str) {
        if (findText(str, sinShape).exists()) {
            this.device.pressBack();
        }
    }

    private boolean findObjClick(String str, String str2, String str3) throws UiObjectNotFoundException {
        int i = 0;
        int i2 = 0;
        while (i < 5) {
            UiObject findText = findText(str, sinShape);
            if (!findText.exists()) {
                findText = findText(str2, sinShape);
            }
            if (!findText.exists()) {
                findText = findText(str3, sinShape);
            }
            if (findText.exists()) {
                c.b();
                System.out.println("开始修改 " + str);
                if (!changeAction()) {
                    return false;
                }
                System.out.println("结束修改 " + str);
                return i2 >= 5;
            } else {
                UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
                uiScrollable.setAsHorizontalList();
                if (i > 2) {
                    uiScrollable.scrollForward();
                }
                uiScrollable.scrollBackward();
                i2 += sinShape;
                c.c();
                i += sinShape;
            }
        }
        if (i2 >= 5) {
        }
    }

    private static Point[] getArcPoints(int i, int i2, int i3, int i4) {
        Random random = new Random();
        Point[] pointArr = new Point[i];
        int nextInt = random.nextInt((i2 * 2) / ovalShape1) + (i2 / ovalShape1);
        int nextInt2 = random.nextInt(i3 / ovalShape2) + (i3 / 6);
        pointArr[0] = new Point(nextInt, nextInt2);
        int nextInt3 = (i2 / ovalShape1) + random.nextInt((i2 * 2) / ovalShape1);
        int nextInt4 = (random.nextInt(i2 / ovalShape2) + nextInt2) + (i3 / 2);
        int i5 = nextInt3 - nextInt;
        int i6 = nextInt4 - nextInt2;
        Object obj = sinShape;
        if (i5 < 0) {
            i5 = nextInt - nextInt3;
            obj = -1;
        }
        if (i5 < i2 / ovalShape1) {
            i5 = i2 / ovalShape1;
            if (nextInt > i2 / 2) {
                nextInt3 = nextInt - (i2 / ovalShape1);
                obj = -1;
            } else {
                nextInt3 = nextInt + (i2 / ovalShape1);
                obj = sinShape;
            }
        }
        int i7 = sinShape;
        while (i7 < i) {
            int i8 = (i7 * i5) / (i - 1);
            int i9 = nextInt + i8;
            int i10 = ((i7 * i6) / (i - 1)) + nextInt2;
            if (obj < null) {
                i9 = nextInt - ((i7 * i5) / (i - 1));
            }
            if (i5 < i2 / ovalShape1) {
                i10 = nextInt4 - ((int) (((double) (nextInt4 - nextInt2)) * Math.cos((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2)))));
            } else if (i4 == sinShape) {
                i10 = ((int) (((double) (nextInt4 - nextInt2)) * Math.sin((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2))))) + nextInt2;
            } else if (i4 == 2) {
                i10 = nextInt4 - ((int) (((double) (nextInt4 - nextInt2)) * Math.cos((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2)))));
            } else if (i4 == ovalShape1) {
                i10 = nextInt4 - ((int) (Math.sqrt(1.0d - (((double) (i8 * i8)) / ((double) (i5 * i5)))) * ((double) i6)));
            } else if (i4 == ovalShape2) {
                i10 = ((int) (Math.sqrt(1.0d - (((double) ((i5 - i8) * (i5 - i8))) / ((double) (i5 * i5)))) * ((double) i6))) + nextInt2;
            } else if (i4 == sShape1) {
                i10 = i / 2;
                i8 = ((i * i6) / ((i - 1) * 2)) + nextInt2;
                i10 = i7 < i10 ? ((int) (((double) (i8 - nextInt2)) * Math.sin((3.141592653589793d * ((double) ((i7 * i5) / i10))) / ((double) (i5 * 2))))) + nextInt2 : nextInt4 - ((int) (((double) (nextInt4 - i8)) * Math.cos((3.141592653589793d * ((double) (((i7 - i10) * i5) / ((i - 1) - i10)))) / ((double) (i5 * 2)))));
            } else if (i4 == miShape1) {
                i10 = nextInt4 - (i6 - (((i6 * i8) * i8) / (i5 * i5)));
            } else if (i4 == miShape2) {
                i10 = (i6 - ((((i5 - i8) * i6) * (i5 - i8)) / (i5 * i5))) + nextInt2;
            } else if (i4 == yuanShape) {
                i9 = ((nextInt3 + nextInt) - ((i6 * i6) / (nextInt - nextInt3))) / 2;
                i9 = nextInt > nextInt3 ? i9 + ((int) Math.sqrt((double) (((i9 - nextInt) * (i9 - nextInt)) - ((nextInt2 - i10) * (nextInt2 - i10))))) : i9 - ((int) Math.sqrt((double) (((i9 - nextInt) * (i9 - nextInt)) - ((nextInt2 - i10) * (nextInt2 - i10)))));
            }
            pointArr[i7] = new Point(i9, i10);
            i7 += sinShape;
        }
        return pointArr;
    }

    private boolean hasCheckCode() throws UiObjectNotFoundException {
        System.out.println(" check has check code input...");
        UiObject a = c.a("com.taobao.taobao:id/checkCodeInputBox");
        debugUiObject(a);
        if (!a.exists()) {
            return false;
        }
        debugUiObject(c.a("com.taobao.taobao:id/checkCodeGetContainer").getChild(new UiSelector().resourceId("com.taobao.taobao:id/checkCodeImg")));
        return true;
    }

    private boolean isLoginSuccess() {
        return false;
    }

    private void openNewSearchPageScript() {
        this.device.pressBack();
        c.b();
        this.device.pressBack();
        c.b();
        this.device.pressHome();
        c.b();
        this.device.pressBack();
        a.g();
        a.f();
        c.e();
    }

    private void openSearchPageScript() {
        this.device.pressBack();
        c.b();
        this.device.pressBack();
        c.b();
        this.device.pressHome();
        c.b();
        this.device.pressBack();
        a.f();
        a.g();
        c.e();
    }

    private void openTaobaoScript() {
        this.device.pressBack();
        c.b();
        this.device.pressBack();
        c.b();
        this.device.pressHome();
        c.b();
        this.device.pressBack();
        a.d();
        a.e();
        c.e();
    }

    private void openZircoScript() {
        this.device.pressBack();
        c.b();
        this.device.pressBack();
        c.b();
        this.device.pressHome();
        c.b("/data/local/tmp/open_zirco.sh");
        c.e();
    }

    public static com.sutuijingling.bean.e parseFromMyTaobaoPage() throws UiObjectNotFoundException {
        com.sutuijingling.bean.e eVar = new com.sutuijingling.bean.e();
        UiObject uiObject = new UiObject(new UiSelector().resourceId("com.taobao.taobao:id/tv_userNick"));
        if (uiObject.exists()) {
            eVar.a(uiObject.getText());
        }
        uiObject = new UiObject(new UiSelector().resourceId("com.taobao.taobao:id/collection_baobei_num"));
        if (uiObject.exists()) {
            eVar.c = NumberUtil.a(uiObject.getText(), 0);
        }
        uiObject = new UiObject(new UiSelector().resourceId("com.taobao.taobao:id/tv_waitToConfirm"));
        if (uiObject.exists()) {
            eVar.e = NumberUtil.a(uiObject.getText(), 0);
        }
        uiObject = new UiObject(new UiSelector().resourceId("com.taobao.taobao:id/tv_waitToShipments"));
        if (uiObject.exists()) {
            eVar.d = NumberUtil.a(uiObject.getText(), 0);
        }
        uiObject = new UiObject(new UiSelector().resourceId("com.taobao.taobao:id/tv_waitToRate"));
        if (uiObject.exists()) {
            eVar.f = NumberUtil.a(uiObject.getText(), 0);
        }
        return eVar;
    }

    private void tryClickClear(UiObject uiObject) throws UiObjectNotFoundException {
        uiObject.clearTextField();
        c.c();
        UiObject findByResId = findByResId("com.taobao.taobao:id/clearButton", sinShape);
        if (findByResId.exists()) {
            c.c(findByResId);
        }
        c.c();
    }

    public void backToHome(UiDevice uiDevice) {
        System.out.println(" return back to home ... ");
        uiDevice.pressBack();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressHome();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressHome();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressBack();
    }

    public void checkAppIsCode() throws UiObjectNotFoundException {
        UiObject findTextContain = findTextContain("停止运行", sinShape);
        UiObject findTextContain2 = findTextContain("无响应", sinShape);
        System.out.println(" check  is close....." + findTextContain);
        if (findTextContain.exists() || findTextContain2.exists()) {
            findTextContain = findText("确定", sinShape);
            if (!findTextContain.exists()) {
                findTextContain = findText("等待", sinShape);
            }
            if (!findTextContain.exists()) {
                findTextContain = findText("是", sinShape);
            }
            if (findTextContain.exists()) {
                c.c(findTextContain);
                c.c();
            }
        }
    }

    protected void checkBiaoqianTip() throws UiObjectNotFoundException {
        UiObject findTextContain = findTextContain("标签", sinShape);
        System.out.println(" check  has more tip....." + findTextContain);
        if (findTextContain.exists()) {
            findTextContain = findTextView("筛选", sinShape);
            if (findTextContain.exists()) {
                c.c(findTextContain);
                c.d();
            }
        }
    }

    public void checkFirstOpenMainTaobao() throws UiObjectNotFoundException {
        UiObject findByResId = findByResId("com.taobao.taobao:id/action_bar", sinShape);
        if (findByResId.exists()) {
            findByResId = findByResId.getChild(new UiSelector().resourceId("com.taobao.taobao:id/up"));
            if (findByResId.exists()) {
                c.d(findByResId);
            }
        }
    }

    protected void checkForGenmodPackageUIGuide() throws UiObjectNotFoundException {
        if ("com.cyanogenmod.trebuchet".equals(new UiObject(new UiSelector()).getPackageName())) {
            UiObject findText = findText("Disgree", sinShape);
            if (findText.exists()) {
                c.c(findText);
                c.d();
            }
            UiSelector text = new UiSelector().className(Button.class).text("OK");
            UiSelector text2 = new UiSelector().className(Button.class).text("确定");
            while (true) {
                UiObject uiObject = new UiObject(text);
                if (!uiObject.exists()) {
                    break;
                }
                c.a(uiObject, 5000);
                c.d();
            }
            while (true) {
                findText = new UiObject(text2);
                if (findText.exists()) {
                    c.a(findText, 5000);
                    c.d();
                } else {
                    return;
                }
            }
        }
    }

    public void checkHaveKnowTip() throws UiObjectNotFoundException {
        UiObject findByResId = findByResId("com.taobao.taobao:id/mytaobao_all_user_guide", sinShape);
        if (findByResId != null && findByResId.exists()) {
            int i = findByResId.getBounds().bottom - 20;
            c.a(this.device, (findByResId.getBounds().right + findByResId.getBounds().left) / 2, i);
            c.e();
        }
    }

    public void checkInvalidTip() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        String str = "淘口令不存在";
        UiObject findTextView = findTextView(str, sinShape);
        if (!findTextView.exists()) {
            findTextView = findText(str, sinShape);
        }
        System.out.println(" check  if has tkl....." + findTextView);
        if (findTextView != null && findTextView.exists()) {
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "淘口令不存在!!!");
        }
    }

    public void checkItemSameTip() {
        if (!findText("相似", sinShape).exists()) {
        }
    }

    protected void checkListCatePage() {
        if (isListCatePage()) {
            this.device.pressBack();
            c.e();
        }
    }

    protected void checkLocationMock() throws UiObjectNotFoundException {
        String str = "拒绝";
        UiObject findTextContain = findTextContain(str, sinShape);
        if (!findTextContain.exists()) {
            findTextContain = findText(str, sinShape);
        }
        System.out.println(" check  has more tip....." + findTextContain);
        if (findTextContain.exists()) {
            c.c(findTextContain);
            c.d();
        }
    }

    public void checkMyHomeTip() throws UiObjectNotFoundException {
        UiObject uiObject = new UiObject(new UiSelector().description("转到上一层级"));
        if (uiObject != null && uiObject.exists()) {
            c.c(uiObject);
            c.e();
        }
    }

    public void checkNetWorkTip() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        UiObject uiObject = new UiObject(new UiSelector().text("记住我的选择"));
        System.out.println(" the no more tip :" + uiObject);
        if (uiObject.exists()) {
            UiObject uiObject2 = new UiObject(new UiSelector().className(CheckBox.class));
            if (uiObject2.exists() && !uiObject2.isChecked()) {
                c.c(uiObject2);
                c.c();
            }
            uiObject2 = new UiObject(new UiSelector().text("允许"));
            if (uiObject2 != null && uiObject2.exists()) {
                c.c(uiObject2);
                c.d();
            }
        }
    }

    public void checkNetflowTip() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        UiObject uiObject = new UiObject(new UiSelector().text(g.a().b()));
        System.out.println(" the no more tip :" + uiObject);
        if (uiObject.exists()) {
            UiObject uiObject2 = new UiObject(new UiSelector().className(CheckBox.class));
            ensureExist(uiObject2, "Why there is tip but no Checkbox???");
            if (!uiObject2.isChecked()) {
                c.c(uiObject2);
            }
            c.a(1000);
            uiObject2 = new UiObject(new UiSelector().text(g.a().c()));
            ensureExist(uiObject2, " Since there exists the no more, tip, where is the yes???");
            c.d(uiObject2);
        }
    }

    public void checkNetworkTip() throws UiObjectNotFoundException {
        String str = "是";
        UiObject findTextView = findTextView(str, sinShape);
        if (!findTextView.exists()) {
            findTextView = findText(str, sinShape);
        }
        System.out.println(" check  app has root right....." + findTextView);
        if (findTextView.exists()) {
            c.c(findTextView);
            c.c();
        }
    }

    protected void checkNewVersionTip() throws UiObjectNotFoundException {
        String str = "稍后再说";
        UiObject findTextView = findTextView(str, sinShape);
        if (!findTextView.exists()) {
            findTextView = findText(str, sinShape);
        }
        System.out.println(" check  has more tip....." + findTextView);
        if (findTextView.exists()) {
            c.c(findTextView);
            c.d();
        }
    }

    public void checkOverTimeTklTip() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        String str = "淘口令已过期";
        UiObject findText = findText(str, sinShape);
        if (!findText.exists()) {
            findText = findTextContain(str, sinShape);
        }
        if (findText != null && findText.exists()) {
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "淘口令已过期");
        }
    }

    protected void checkSameTip() throws UiObjectNotFoundException {
        UiObject findTextContain = findTextContain("找相似", sinShape);
        System.out.println(" check  has more tip....." + findTextContain);
        if (findTextContain.exists()) {
            findTextContain = findTextView("筛选", sinShape);
            if (findTextContain.exists()) {
                c.c(findTextContain);
                c.d();
            }
        }
    }

    public void checkSavePhotoMask() {
        if (findText("保存到相册", sinShape).exists()) {
            try {
                c.c(findText("取消", sinShape));
            } catch (UiObjectNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

    protected void checkStopTBTip() throws UiObjectNotFoundException {
        String str = "等待";
        UiObject findTextView = findTextView(str, sinShape);
        if (!findTextView.exists()) {
            findTextView = findText(str, sinShape);
        }
        System.out.println(" check  is stop tip....." + findTextView);
        if (findTextView.exists()) {
            c.c(findTextView);
            c.c();
        }
    }

    public boolean checkTBLogin(boolean z) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        b.b(" check taobao is login !!!", new Object[0]);
        checkAppIsCode();
        checkStopTBTip();
        checkLocationMock();
        openMyTaobao();
        c.c();
        if (isTBLoginPage()) {
            return false;
        }
        if (!isMyTaobao()) {
            c.f();
        }
        checkNewVersionTip();
        checkHaveKnowTip();
        checkMyHomeTip();
        if (!isMyTaobao()) {
            simpleDragScroll(false);
            c.c();
            simpleDragScroll(false);
            c.c();
            checkNewVersionTip();
            checkHaveKnowTip();
            checkMyHomeTip();
            c.d();
        }
        if (!isMyTaobao()) {
            openMyTaobao();
            c.d();
            if (!isMyTaobao()) {
                simpleDragScroll(false);
                c.c();
                simpleDragScroll(false);
                c.c();
                checkNewVersionTip();
                checkHaveKnowTip();
                checkMyHomeTip();
                c.d();
            }
        }
        if (!isMyTaobao()) {
            return false;
        }
        String a = parseFromMyTaobaoPage().a();
        System.out.println("has login user is: " + a);
        if (org.apache.commons.lang.c.a(a)) {
            return false;
        }
        String substring = a.length() > ovalShape1 ? a.substring(0, 3) : a;
        AccountBean f = b.f();
        if (z || f == null || org.apache.commons.lang.c.a(f.getRealname()) || !f.getRealname().startsWith(substring)) {
            substring = b.c();
            Object accountBean = new AccountBean();
            accountBean.setRealname(a);
            accountBean.encryptRealName(substring);
            b.b(new f().b(accountBean));
        }
        return true;
    }

    protected void checkTaoqianggouTipDialog() throws UiObjectNotFoundException {
        UiObject findByResId = findByResId("com.taobao.taobao:id/ll_user_guide", sinShape);
        if (findByResId.exists()) {
            Rect bounds = findByResId.getBounds();
            c.a(this.device, bounds.centerX(), bounds.centerY());
            c.c();
        }
    }

    protected void checkWebviewLayout() throws UiObjectNotFoundException {
        UiObject findByResId = findByResId("com.taobao.taobao:id/overlay_webview", sinShape);
        if (findByResId.exists()) {
            Rect bounds = findByResId.getBounds();
            c.a(this.device, bounds.centerX(), bounds.centerY());
            c.c();
        }
    }

    public void debugAll() throws UiObjectNotFoundException {
        debugAll(new UiSelector().focusable(true));
        debugAll(new UiSelector().longClickable(true));
        debugAll(new UiSelector().clickable(true));
        debugAll(new UiSelector().className(EditText.class));
    }

    public void debugAll(UiSelector uiSelector) throws UiObjectNotFoundException {
        for (int i = 0; i < 15; i += sinShape) {
            UiObject uiObject = new UiObject(uiSelector.instance(i));
            System.out.println(" index<" + i + "> :");
            if (uiObject.exists()) {
                int childCount = uiObject.getChildCount();
                debugUiObject(uiObject);
                String text = uiObject.getText();
                if (!("注册".equals(text) || "找回密码".equals(text) || "登录".equals(text) || "淘宝账户登录".equals(text))) {
                    c.a(1000);
                    if (childCount <= 0) {
                    }
                }
            }
        }
    }

    public void debugChildren(UiObject uiObject) throws UiObjectNotFoundException {
        System.out.println(" scroll childs:" + uiObject.getChildCount());
        uiObject.getChildCount();
        for (int i = 0; i < 20; i += sinShape) {
            UiObject child = uiObject.getChild(new UiSelector().instance(i));
            if (child.exists()) {
                System.out.println("list <" + i + "> child num:" + child.getChildCount() + " with list:" + child);
                debugUiObject(child);
            }
        }
    }

    public void debugMyTaobaoPageInfo() {
    }

    public void debugRawPage() throws UiObjectNotFoundException {
        UiObject uiObject = new UiObject(new UiSelector());
        System.out.println(" scroll childs:" + uiObject.getChildCount());
        int childCount = uiObject.getChildCount();
        for (int i = 0; i < childCount; i += sinShape) {
            UiObject child = uiObject.getChild(new UiSelector().instance(i));
            System.out.println("list <" + i + "> child num:" + child.getChildCount() + " with list:" + child);
            debugUiObject(child);
        }
    }

    public void debugScrollPage() throws UiObjectNotFoundException {
        UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
        if (uiScrollable.exists()) {
            System.out.println(" scroll childs:" + uiScrollable.getChildCount());
            int childCount = uiScrollable.getChildCount();
            for (int i = 0; i < childCount; i += sinShape) {
                UiObject child = uiScrollable.getChild(new UiSelector().instance(i));
                System.out.println("list <" + i + "> child num:" + child.getChildCount() + " with list:" + child);
                debugUiObject(child);
            }
            return;
        }
        debugRawPage();
    }

    public void debugTree() throws UiObjectNotFoundException {
        UiObject uiObject = new UiObject(new UiSelector().instance(0));
        System.out.println(" focusable parent : <" + 0 + "> :");
        debugUiObject(uiObject);
        recursiveTree(uiObject, 0);
    }

    public void debugUiObject(UiObject uiObject) throws UiObjectNotFoundException {
        if (uiObject != null && uiObject.exists()) {
            System.out.println(uiObject.getClassName() + ":desc[" + uiObject.getContentDescription() + "]<<" + uiObject);
            System.out.println("<" + uiObject.getText() + ">:" + uiObject.getBounds() + "-" + uiObject.getChildCount());
        }
    }

    public v doAccountInput(String str, String str2) throws UiObjectNotFoundException {
        UiObject uiObject = new UiObject(new UiSelector().focusable(true).instance(0));
        UiSelector className = new UiSelector().focusable(true).className(EditText.class);
        for (int i = 0; i < 10; i += sinShape) {
            UiObject child = uiObject.getChild(className.instance(i));
            if (child.exists()) {
                System.out.println(" index<" + i + "> :");
                System.out.println(child.getClassName() + ":" + child.getContentDescription() + "<<" + child);
                System.out.println(child.getText() + ":" + child.getBounds() + "-" + child.getChildCount());
            }
        }
        UiObject child2 = uiObject.getChild(className.instance(0));
        UiObject child3 = uiObject.getChild(className.instance(sinShape));
        if (!child2.exists()) {
            return v.a("no 用户名输入框找不到");
        }
        if (!child3.exists()) {
            return v.a("no 密码输入找不到 ");
        }
        child2.clearTextField();
        child3.clearTextField();
        c.c();
        ensureInput(child2, str);
        c.c(child2);
        c.a(200);
        ensureInput(child3, str2);
        c.a(200);
        return v.e;
    }

    public void doChangeChuanhao() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        c.c();
        if (findObjClick("单串号", "双串号", "不记串号")) {
            c.f();
            if (findObjClick("蓝牙地址", "WIFI地址", "序列号")) {
                c.d();
                for (int i = 0; i < 5; i += sinShape) {
                    UiObject findText = findText("确定", 2);
                    if (findText.exists()) {
                        c.c(findText);
                        c.c();
                        break;
                    }
                    c.c();
                }
                c.c();
                return;
            }
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "找不到修改蓝牙地址页面");
        }
        throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "找不到修改串号页面");
    }

    public void doEnsureHomeLauncher() throws UiObjectNotFoundException {
        if (findText("选择主屏幕应用", 2).exists()) {
            UiObject findText = findText("Holo Launcher", 2);
            if (findText.exists()) {
                c.c(findText);
                c.c();
                UiObject findText2 = findText("始终", sinShape);
                if (findText.exists()) {
                    c.c(findText2);
                    c.c();
                    findText = findText("取消", sinShape);
                    if (findText.exists()) {
                        c.c(findText);
                        return;
                    }
                    return;
                }
                System.out.println(" Not always has always to click...");
                return;
            }
            System.out.println(" no xiaoui home to click...");
            return;
        }
        System.out.println(" not to select home page application");
    }

    public boolean doLogin(AccountBean accountBean) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        checkLocationMock();
        UiObject findByResId = findByResId("com.taobao.taobao:id/accountCompleteTextView", 2);
        UiObject child = findByResId("com.taobao.taobao:id/userPasswordInput", 2).getChild(new UiSelector().className(EditText.class));
        findByResId.clearTextField();
        child.clearTextField();
        c.c();
        ensureNameInput(findByResId, accountBean.getUsername());
        c.c(findByResId);
        c.c();
        ensurePassword(child, accountBean.getRealPswd());
        c.c();
        findByResId = c.a("com.taobao.taobao:id/loginButton");
        ensureExist(findByResId, " 登录页面怎么连个登录按钮都没有.....");
        checkNewVersionTip();
        System.out.println(" login btn clicked....");
        c.a(findByResId, 2000);
        c.e();
        checkLocationMock();
        checkNewVersionTip();
        if (hasCheckCode()) {
            System.out.println(" check code has come....！！！！！");
            throw new com.sutuijingling.result.c(9003, "需要验证码！！！");
        } else if (findTextContain("系统提示", sinShape).exists()) {
            throw new com.sutuijingling.result.c(9003, "帐号存在风险");
        } else if (isLoginPage()) {
            System.out.println("after login, is still login page... some thing wrong??");
            throw new com.sutuijingling.result.c(9003, "登录失败！");
        } else if (hasCheckCode()) {
            System.out.println(" check code has come....！！！！！");
            throw new com.sutuijingling.result.c(9003, "需要验证码！！！");
        } else if (findTextContain("系统提示", sinShape).exists()) {
            throw new com.sutuijingling.result.c(9003, "帐号存在风险");
        } else if (isLoginPage()) {
            throw new com.sutuijingling.result.c(9003, "登录失败！");
        } else {
            writeIfCanBackup(true);
            return true;
        }
    }

    public void doLogout() throws com.sutuijingling.result.c, UiObjectNotFoundException {
        UiObject a = c.a("com.taobao.taobao:id/btn_logout");
        ensureExist(a, " 怎么没有 登出按钮");
        c.d(a);
        c.d(c.a("com.taobao.taobao:id/logout_button"));
        c.d();
    }

    public v doMainLogin(UiDevice uiDevice) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        doOpenTaobao();
        UiObject findText = findText(g.a().d(), 3);
        if (!findText.exists()) {
            return v.a("No my taobao  Btn");
        }
        c.a(findText, 10000);
        findText = new UiObject(new UiSelector().className(EditText.class));
        if (!findText.exists()) {
            return v.a("no username input");
        }
        findText.clearTextField();
        findText.setText("tb_tevonol333");
        findText = new UiObject(new UiSelector().className(ScrollView.class));
        if (!findText.exists()) {
            return v.a("no password input not found.....");
        }
        findText.clearTextField();
        findText.setText("xznmcvb@67865432");
        c.a(3000);
        return v.e;
    }

    public void doOpenApp(UiDevice uiDevice, String str) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        checkForGenmodPackageUIGuide();
        UiObject findText = findText("程序列表", 2);
        if (!findText.exists()) {
            findText = findText("App drawer", 2);
        }
        System.out.println("find app list :");
        debugUiObject(findText);
        if (findText.exists()) {
            System.out.println(" click app list:");
            c.a(findText, 5000);
            c.c();
            if (!findByResId("com.mobint.hololauncher:id/apps_customize_pane", sinShape).exists()) {
                uiDevice.pressBack();
                c.a(findText, 5000);
                c.c();
            }
        }
        c.d();
        findText = findText(str, 2);
        if (findText.exists()) {
            System.out.println("app name contain equals[" + str + "]: " + findText);
            c.d(findText);
            return;
        }
        findText = findTextContain(str, 2);
        if (findText.exists()) {
            System.out.println("app name contain contains[" + str + "]:" + findText);
            c.d(findText);
            return;
        }
        throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND);
    }

    public void doOpenChuanhao(UiDevice uiDevice) throws com.sutuijingling.result.c, UiObjectNotFoundException {
        uiDevice.pressBack();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressHome();
        c.b();
        uiDevice.pressBack();
        a.i();
        c.e();
        if (!isPackageMTK()) {
            a.j();
            c.e();
        }
    }

    public void doOpenConfig(UiDevice uiDevice) throws com.sutuijingling.result.c {
        uiDevice.pressBack();
        c.b();
        uiDevice.pressBack();
        c.b();
        uiDevice.pressHome();
        c.b();
        uiDevice.pressBack();
        a.l();
        c.e();
    }

    public void doOpenMainHome() throws UiObjectNotFoundException {
        this.device.pressBack();
        this.device.pressBack();
        this.device.pressBack();
        this.device.pressBack();
        this.device.pressHome();
        c.c();
        doEnsureHomeLauncher();
        this.device.pressBack();
        c.a(1000);
        this.device.pressBack();
    }

    public v doOpenMyTaobao(UiDevice uiDevice) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        doOpenTaobao();
        UiObject findText = findText(g.a().d(), 3);
        if (!findText.exists()) {
            return new v(false, "No mytaobao Btn", "");
        }
        c.a(findText, 10000);
        return new v(true, " Open my taobao successfully", "");
    }

    public void doOpenMyTaobaoScript() {
        b.b(" open res : " + a.b("am start -n com.taobao.taobao/com.taobao.tao.mytaobao.MyTaoBaoActivity"), new Object[0]);
        c.e();
    }

    public void doOpenSearchPage() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        openNewSearchPageScript();
        if (isSearchPage()) {
            b.b(" it's already the serach result page..", new Object[0]);
            return;
        }
        checkAppIsCode();
        if (!isPackageTaobao()) {
            openTaobaoScript();
            c.e();
            checkAppIsCode();
        }
        checkLocationMock();
        c.c();
        UiObject findSearchPageBtn = findSearchPageBtn();
        if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
            checkNetflowTip();
            c.e();
            findSearchPageBtn = findSearchPageBtn();
            if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                checkNetflowTip();
                c.e();
                findSearchPageBtn = findSearchPageBtn();
                if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                    checkTaoQiangGou();
                    checkTaoJinBi();
                    checkFirstOpenMainTaobao();
                    c.e();
                    findSearchPageBtn = findSearchPageBtn();
                    if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                        checkWebviewLayout();
                        c.e();
                        findSearchPageBtn = findSearchPageBtn();
                        if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                            checkNewVersionTip();
                            return;
                        } else {
                            c.d(findSearchPageBtn);
                            return;
                        }
                    }
                    c.d(findSearchPageBtn);
                    return;
                }
                c.d(findSearchPageBtn);
                return;
            }
            c.d(findSearchPageBtn);
            return;
        }
        c.d(findSearchPageBtn);
    }

    public void doOpenTBAndDirectToItem() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        if (isPackageTaobao()) {
            backToHome(this.device);
        }
        openTaobaoScript();
        c.c();
        checkLocationMock();
        checkInvalidTip();
        checkOverTimeTklTip();
        UiObject findTKLAccessBtn = findTKLAccessBtn();
        if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
            c.c();
            checkNetworkTip();
            checkInvalidTip();
            checkOverTimeTklTip();
            findTKLAccessBtn = findTKLAccessBtn();
            if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                c.c();
                checkNetflowTip();
                findTKLAccessBtn = findTKLAccessBtn();
                if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                    c.e();
                    checkNetflowTip();
                    checkInvalidTip();
                    checkOverTimeTklTip();
                    findTKLAccessBtn = findTKLAccessBtn();
                    if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                        checkNewVersionTip();
                        findTKLAccessBtn = findTKLAccessBtn();
                        if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                            checkTaoQiangGou();
                            checkTaoJinBi();
                            checkFirstOpenMainTaobao();
                            checkInvalidTip();
                            checkOverTimeTklTip();
                            c.e();
                            findTKLAccessBtn = findTKLAccessBtn();
                            if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                                checkWebviewLayout();
                                c.e();
                                findTKLAccessBtn = findTKLAccessBtn();
                                if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                                    checkNewVersionTip();
                                    checkInvalidTip();
                                    checkOverTimeTklTip();
                                    c.e();
                                    findTKLAccessBtn = findTKLAccessBtn();
                                    if (findTKLAccessBtn == null || !findTKLAccessBtn.exists()) {
                                        throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "淘口令失效，没有淘口令窗口!");
                                    }
                                    c.d();
                                    c.d(findTKLAccessBtn);
                                    c.f();
                                    return;
                                }
                                c.d();
                                c.d(findTKLAccessBtn);
                                c.f();
                                return;
                            }
                            c.d();
                            c.d(findTKLAccessBtn);
                            c.f();
                            return;
                        }
                        c.d();
                        c.d(findTKLAccessBtn);
                        c.f();
                        return;
                    }
                    c.d();
                    c.d(findTKLAccessBtn);
                    c.f();
                    return;
                }
                c.d();
                c.d(findTKLAccessBtn);
                c.f();
                return;
            }
            c.d();
            c.d(findTKLAccessBtn);
            c.f();
            return;
        }
        c.d();
        c.d(findTKLAccessBtn);
        c.f();
    }

    public void doOpenTaobao() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        openTaobaoScript();
        if (isSearchPage()) {
            b.b(" it's already the serach result page..", new Object[0]);
            return;
        }
        checkNetflowTip();
        checkNewVersionTip();
        checkAppIsCode();
        checkLocationMock();
        c.c();
        UiObject findSearchPageBtn = findSearchPageBtn();
        if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
            checkNetflowTip();
            c.c();
            findSearchPageBtn = findSearchPageBtn();
            if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                checkNewVersionTip();
                findSearchPageBtn = findSearchPageBtn();
                if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                    checkTaoQiangGou();
                    checkTaoJinBi();
                    checkFirstOpenMainTaobao();
                    c.e();
                    findSearchPageBtn = findSearchPageBtn();
                    if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                        checkWebviewLayout();
                        c.e();
                        findSearchPageBtn = findSearchPageBtn();
                        if (findSearchPageBtn == null || !findSearchPageBtn.exists()) {
                            checkNewVersionTip();
                        }
                    }
                }
            }
        }
    }

    public void doOpenZirco() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        System.out.println(" start to load zirco...");
        openZircoScript();
    }

    public boolean doViewItem() throws UiObjectNotFoundException {
        UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
        if (!uiScrollable.exists()) {
            return false;
        }
        int i = 0;
        while (i < this.defaultScrollTime) {
            try {
                uiScrollable.scrollForward(5);
                c.a((long) (rand.nextInt(HttpStatus.SC_BAD_REQUEST) + HttpStatus.SC_MULTIPLE_CHOICES));
                i += sinShape;
            } catch (UiObjectNotFoundException e) {
                e.printStackTrace();
                return false;
            }
        }
        return true;
    }

    public void doWriteConfig() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        c.e();
        String str = "清空淘宝";
        UiObject findText = findText(str, sinShape);
        for (int i = 0; i < 5 && !findText.exists(); i += sinShape) {
            c.e();
            UiScrollable findScroll = findScroll();
            findScroll.setAsVerticalList();
            findScroll.scrollBackward();
            c.c();
            findText = findText(str, 2);
        }
        if (!findText.exists()) {
            ensureExist(findText, "找不到清空淘宝按钮????");
        }
        c.c(findText);
        c.f();
        findText = findText("随机生成", 2);
        if (!findText.exists()) {
            ensureExist(findText, "找不到随机生成按钮????");
        }
        c.c(findText);
        c.c();
        UiObject findText2 = findText("保存并重启", 2);
        if (!findText2.exists()) {
            ensureExist(findText, "找不到保存并重启按钮????");
        }
        c.c(findText2);
        c.g();
        c.c();
    }

    public void ensureExist(UiObject uiObject, String str) throws com.sutuijingling.result.c {
        if (uiObject == null) {
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, str);
        } else if (!uiObject.exists()) {
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, str);
        }
    }

    protected void ensureForwardPoint() {
        int displayWidth = this.device.getDisplayWidth();
        int displayHeight = this.device.getDisplayHeight();
        int nextInt = rand.nextInt(ovalShape1) + 7;
        Point[] pointArr = new Point[nextInt];
        this.forwardPoints = new Point[nextInt];
        System.out.println("arc line type:" + ovalShape2);
        Point[] arcPoints = getArcPoints(nextInt, displayWidth, displayHeight, ovalShape2);
        for (displayWidth = 0; displayWidth < nextInt; displayWidth += sinShape) {
            this.forwardPoints[displayWidth] = arcPoints[(nextInt - 1) - displayWidth];
        }
        this.backwardPoints = arcPoints;
    }

    public void ensureInput(UiObject uiObject, String str) throws UiObjectNotFoundException {
        ensureInput(uiObject, str, false);
    }

    public void ensureInput(UiObject uiObject, String str, boolean z) throws UiObjectNotFoundException {
        int i = 0;
        System.out.println(String.format("ensureInput:editor, content".replaceAll(", ", "=%s, ") + "=%s", new Object[]{uiObject, str}));
        if (com.sutuijingling.utils.e.a(str)) {
            uiObject.clearTextField();
            return;
        }
        uiObject.setText(a.a.a.a.a.a.a(str));
        c.c();
        String text = uiObject.getText();
        System.out.println(" content [" + str + "] -  res:" + text);
        if (!str.equals(text)) {
            c.c();
            if (z) {
                uiObject.setText(a.a.a.a.a.a.a("123456789"));
            }
            uiObject.clearTextField();
            b.b("  start to clear...", new Object[0]);
            while (i < 15) {
                c.a();
                this.device.pressDelete();
                c.a();
                this.device.pressKeyCode(73);
                i += sinShape;
            }
            c.d();
            uiObject.setText(a.a.a.a.a.a.a(str));
            c.c();
            String text2 = uiObject.getText();
            System.out.println(" content [" + str + "] -  res:" + text2);
            if (!str.equals(text2)) {
                if (z) {
                    uiObject.setText(a.a.a.a.a.a.a("123456789"));
                }
                uiObject.clearTextField();
                c.c();
                uiObject.setText(a.a.a.a.a.a.a(str));
                c.e();
            }
        }
    }

    public boolean ensureLogin(AccountBean accountBean) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        return ensureLogin(accountBean, true);
    }

    public boolean ensureLogin(AccountBean accountBean, boolean z) throws UiObjectNotFoundException, com.sutuijingling.result.c {
        boolean z2 = true;
        b.b(" ensure login acc:" + accountBean, new Object[0]);
        checkStopTBTip();
        checkLocationMock();
        if (z) {
            openMyTaobao();
            c.c();
        }
        if (!isMyTaobao()) {
            c.f();
        }
        checkNewVersionTip();
        checkHaveKnowTip();
        checkMyHomeTip();
        if (!isMyTaobao()) {
            simpleDragScroll(false);
            c.d();
            checkMyHomeTip();
        }
        if (isMyTaobao()) {
            String a = parseFromMyTaobaoPage().a();
            System.out.println("has login user is: " + a + ", need login user is :" + accountBean.getUsername());
            if (org.apache.commons.lang.c.a(a, accountBean.getUsername())) {
                this.device.pressBack();
            } else {
                if (!org.apache.commons.lang.c.a(a) && a.length() > 6) {
                    if (accountBean.getUsername().contains(a.substring(0, 6))) {
                        System.out.println(accountBean.getUsername() + " is just too long");
                        this.device.pressBack();
                    }
                }
                doLogout();
            }
            return z2;
        }
        z2 = doLogin(accountBean);
        checkNewVersionTip();
        checkHaveKnowTip();
        checkMyHomeTip();
        c.c();
        if (isMyTaobao()) {
            this.device.pressBack();
        }
        return z2;
    }

    public void ensureNameInput(UiObject uiObject, String str) throws UiObjectNotFoundException {
        String str2 = "ensureInputName:editor, content".replaceAll(", ", "=%s, ") + "=%s";
        System.out.println(String.format(str2, new Object[]{uiObject, str}));
        if (com.sutuijingling.utils.e.a(str)) {
            uiObject.clearTextField();
            return;
        }
        uiObject.setText(a.a.a.a.a.a.a(str));
        str2 = uiObject.getText();
        System.out.println(" content [" + str + "] -  res:" + str2);
        if (!str.equals(str2)) {
            c.c();
            tryClickClear(uiObject);
            c.c();
            uiObject.setText(a.a.a.a.a.a.a(str));
            c.c();
            str2 = uiObject.getText();
            System.out.println(" content [" + str + "] -  res:" + str2);
            if (!str.equals(str2)) {
                c.c();
                tryClickClear(uiObject);
                c.c();
                uiObject.setText(a.a.a.a.a.a.a(str));
                c.e();
            }
        }
    }

    public void ensurePassword(UiObject uiObject, String str) throws UiObjectNotFoundException {
        uiObject.setText("");
        tryClickClear(uiObject);
        c.c();
        uiObject.setText(str);
        String text = uiObject.getText();
        System.out.println(" content [" + str + "] -  res:" + text);
        if (!str.equals(text)) {
            c.c();
        }
    }

    public void enterIntoMyTaobao() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        b.b(" start to enter into my taobao...", new Object[0]);
        c.d();
        if (isTaobaoMainPage()) {
            UiObject findTextView = findTextView("我的淘宝", 2);
            debugUiObject(findTextView);
            ensureExist(findTextView, " 首页怎么没有我的淘宝这个按钮");
            b.b(" start to click", new Object[0]);
            c.d(findTextView);
        }
    }

    public String fetchPackage() {
        try {
            return new UiObject(new UiSelector()).getPackageName();
        } catch (UiObjectNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    public UiObject findAllObjText(UiSelector uiSelector, UiSelector uiSelector2, UiSelector uiSelector3, String str) throws UiObjectNotFoundException {
        UiScrollable uiScrollable = new UiScrollable(uiSelector);
        return uiScrollable.exists() ? uiScrollable.getChildByText(uiSelector3, str, true) : new UiCollection(uiSelector2).getChildByText(uiSelector3, str);
    }

    protected UiObject findBackToTopBtn() {
        return findByResId("com.taobao.taobao:id/detail_main_bottom_gotop", sinShape);
    }

    public UiObject findByResId(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().resourceId(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    protected UiObject findByResIdAndText(String str, int i, String str2) {
        return findByResIdAndTextWithInstance(str, i, str2, 0);
    }

    protected UiObject findByResIdAndTextWithInstance(String str, int i, String str2, int i2) {
        int i3 = 0;
        UiObject uiObject = null;
        while (true) {
            int i4 = i3 + sinShape;
            if (i3 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().resourceId(str).text(str2).instance(i2));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i3 = i4;
            } else {
                i3 = i4;
            }
        }
        return uiObject;
    }

    protected UiObject findByResIdWithInstance(String str, int i, int i2) {
        String str2 = "";
        return findByResIdAndTextWithInstance(str, i, "", i2);
    }

    public UiObject findDesc(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().description(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public UiObject findDescContains(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().descriptionContains(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public void findParent() throws UiObjectNotFoundException {
        UiObject fromParent = new UiObject(new UiSelector().text("登录密码")).getFromParent(new UiSelector()).getFromParent(new UiSelector());
        System.out.println("<>" + fromParent.getClassName() + fromParent.getText());
    }

    public UiScrollable findScroll() {
        return new UiScrollable(new UiSelector().scrollable(true));
    }

    public UiObject findScrollText(String str, int i) throws UiObjectNotFoundException {
        int i2 = 0;
        UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
        b.b("find scroll :" + uiScrollable, new Object[0]);
        if (!uiScrollable.exists()) {
            return new UiObject(new UiSelector().text(str));
        }
        while (true) {
            UiObject child = uiScrollable.getChild(new UiSelector().className(TextView.class).text(str));
            if (child.exists()) {
                return child;
            }
            uiScrollable.scrollForward(80);
            c.b();
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                return child;
            }
            i2 = i3;
        }
    }

    public UiObject findScrollTextContain(String str, int i) throws UiObjectNotFoundException {
        int i2 = 0;
        UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true));
        if (!uiScrollable.exists()) {
            return new UiObject(new UiSelector().textContains(str));
        }
        while (true) {
            UiObject child = uiScrollable.getChild(new UiSelector().className(TextView.class).textContains(str));
            if (child.exists()) {
                return child;
            }
            uiScrollable.scrollForward(80);
            c.a(300);
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                return child;
            }
            i2 = i3;
        }
    }

    public UiObject findSearchPageBtn() {
        UiObject a = c.a("com.taobao.taobao:id/home_searchedit");
        if (a.exists()) {
            System.out.println(" use the home search edit id...");
            return a;
        }
        a = c.a("com.taobao.taobao:id/searchedit");
        if (a.exists()) {
            System.out.println(" use the search edit res id...");
            return a;
        }
        a = c.a("com.taobao.taobao:id/searchEdit");
        if (a.exists()) {
            System.out.println(" use the search Edit res id...");
            return a;
        }
        a = findText("寻找宝贝", 2);
        if (a.exists()) {
            System.out.println(" search item exist.....");
            return a;
        }
        a = findText("寻找宝贝、店铺", 2);
        if (a.exists()) {
            System.out.println(" find item and shop....");
            return a;
        }
        a = findTextContain("寻找宝贝", 2);
        if (a.exists()) {
            System.out.println(" find the search item...");
            return a;
        }
        a = findText("搜1111试试", 2);
        if (a.exists()) {
            System.out.println(" find the 1111 search item");
            return a;
        }
        System.out.println(" no search btn...... so all over...");
        return null;
    }

    protected UiObject findShopTitleObj() {
        return findByResId("com.taobao.taobao:id/detail_main_seller_title", sinShape);
    }

    public UiObject findTKLAccessBtn() {
        if (!isTaokoulingFrame()) {
            return null;
        }
        UiObject findByResId = findByResId("com.taobao.taobao:id/contacts_clipwatcher_access", 2);
        if (findByResId.exists()) {
            return findByResId;
        }
        findByResId = findText("查看", sinShape);
        if (findByResId.exists()) {
            return findByResId;
        }
        findByResId = findText("立即查看", sinShape);
        if (findByResId.exists()) {
            return findByResId;
        }
        findByResId = findTextContain("查看", sinShape);
        return findByResId.exists() ? findByResId : null;
    }

    public UiObject findText(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().text(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public UiObject findTextContain(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().textContains(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public UiObject findTextView(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().className(TextView.class).text(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public UiObject findTextViewContains(String str, int i) {
        int i2 = 0;
        UiObject uiObject = null;
        while (true) {
            int i3 = i2 + sinShape;
            if (i2 >= i) {
                break;
            }
            uiObject = new UiObject(new UiSelector().className(TextView.class).textContains(str));
            if (uiObject.exists()) {
                break;
            } else if (i > sinShape) {
                c.c();
                i2 = i3;
            } else {
                i2 = i3;
            }
        }
        return uiObject;
    }

    public UiObject findTexts(String[] strArr, int i) {
        int length = strArr.length;
        UiObject uiObject = null;
        for (int i2 = 0; i2 < length; i2 += sinShape) {
            uiObject = findText(strArr[i2], i);
            if (uiObject.exists()) {
                break;
            }
        }
        return uiObject;
    }

    public UiObject findWeitaoView() {
        UiObject findByResId = findByResId("com.taobao.taobao:id/we_detail_container", sinShape);
        if (findByResId != null && findByResId.exists()) {
            return findByResId;
        }
        findByResId = findByResId("com.taobao.taobao:id/tf_viewpager", sinShape);
        if (findByResId.exists()) {
            return findByResId;
        }
        findByResId = findByResId("com.taobao.taobao:id/tf_webview", sinShape);
        return !findByResId.exists() ? null : findByResId;
    }

    public AccountBean getAccParams() {
        return this.accParams;
    }

    protected String getActionBarTitle() {
        String str = null;
        UiObject findByResId = findByResId("com.taobao.taobao:id/action_bar_title", sinShape);
        if (findByResId.exists()) {
            try {
                str = findByResId.getText();
            } catch (UiObjectNotFoundException e) {
                e.printStackTrace();
            }
        }
        return str;
    }

    public v getLoginUser(UiDevice uiDevice) throws UiObjectNotFoundException {
        UiSelector className = new UiSelector().className(TextView.class);
        for (int i = 0; i < 20; i += sinShape) {
            UiObject uiObject = new UiObject(className.instance(i));
            if (uiObject.exists()) {
                System.out.println("<" + i + ">");
                debugUiObject(uiObject);
            }
        }
        return null;
    }

    public long getMissionId() {
        return this.missionId;
    }

    protected boolean hasActionBarLayout() {
        return findByResId("com.taobao.taobao:id/action_bar_content_layout", sinShape).exists();
    }

    public boolean hasResId(String str, int i) {
        return findByResId(str, i).exists();
    }

    protected boolean hasSearchBar() {
        return hasResId("com.taobao.taobao:id/tbsearchdoor_searchbar", 2);
    }

    protected boolean hasSearchEditor() {
        return hasResId("com.taobao.taobao:id/searchedit", 2);
    }

    protected boolean hasSearchResultGidMid() {
        return hasResId("com.taobao.taobao:layout/tbsearch_item_mid_improve", 2);
    }

    protected boolean hasSearchResultList() {
        return hasResId("com.taobao.taobao:layout/tbsearch_item_list_improve", 2);
    }

    public void initEnv() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        f fVar = new f(this.device);
        System.out.println(" init cacnel");
        fVar.c();
        c.c();
    }

    public void initInputEnv() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        f fVar = new f(this.device);
        System.out.println(" init input method");
        fVar.b();
    }

    protected boolean isCollectionItemPage() {
        return findText("我收藏的宝贝", 2).exists();
    }

    public boolean isHoloLauncher() throws UiObjectNotFoundException {
        return "com.mobint.hololauncher".equals(new UiObject(new UiSelector()).getPackageName());
    }

    public boolean isHomePage() {
        return findByResId("com.taobao.taobao:id/scan_code_icon", sinShape).exists() || findByResId("com.taobao.taobao:id/home_searchbar", sinShape).exists();
    }

    public boolean isHomeTaobaoPage() {
        return isTaobaoMainPage();
    }

    protected boolean isItemCatePage() {
        return findByResId("com.taobao.taobao:id/tbsearch_shop_cat_list", sinShape).exists() || findByResId("com.taobao.taobao:id/shop_category_group_item1_title", sinShape).exists() || findByResId("com.taobao.taobao:id/categoryTextview", sinShape).exists() || findByResId("com.taobao.taobao:id/searchgoodsMid", sinShape).exists() || findByResId("com.taobao.taobao:id/searchgoodsMid", sinShape).exists();
    }

    protected boolean isItemCommentPage() {
        UiObject findByResId = findByResId("com.taobao.taobao:id/action_bar_title", sinShape);
        if (!findByResId.exists()) {
            return false;
        }
        try {
            String text = findByResId.getText();
            return !org.apache.commons.lang.c.a(text) ? text.startsWith("评价(") || "评价".equals(text) : false;
        } catch (UiObjectNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }

    protected boolean isItemDetail() {
        return findByResId("com.taobao.taobao:id/mainpages", sinShape).exists() || "宝贝详情".equals(getActionBarTitle()) || findByResId("com.taobao.taobao:id/detail_main_title", sinShape).exists() || findByResId("com.taobao.taobao:id/detail_main_seller_shopinfo", sinShape).exists();
    }

    public boolean isItemDetailPage() {
        return findText("加入购物车", sinShape).exists() || findText("立即购买", sinShape).exists();
    }

    protected boolean isListCatePage() {
        return "类目".equals(getActionBarTitle());
    }

    protected boolean isLoginPage() {
        return hasResId("com.taobao.taobao:id/title_bar_back_button", sinShape);
    }

    protected boolean isMyTaobao() {
        return findByResId("com.taobao.taobao:id/text_mytaobao_title", sinShape).exists() || findByResId("com.taobao.taobao:id/tv_userNick", sinShape).exists();
    }

    public boolean isPackage(String str, int i) {
        if (i < sinShape) {
            i = sinShape;
        }
        while (true) {
            int i2 = i - 1;
            if (i <= 0) {
                return false;
            }
            try {
                if (str.equals(new UiObject(new UiSelector()).getPackageName())) {
                    return true;
                }
                c.e();
                i = i2;
            } catch (Throwable e) {
                b.a(e, e.getMessage(), new Object[0]);
                i = i2;
            }
        }
    }

    public boolean isPackageImes(int i) {
        return isPackage("com.imes", i);
    }

    public boolean isPackageMTK() throws UiObjectNotFoundException {
        return "org.imei.mtk65xx".equals(new UiObject(new UiSelector()).getPackageName());
    }

    public boolean isPackageTaobao() throws UiObjectNotFoundException {
        return "com.taobao.taobao".equals(new UiObject(new UiSelector()).getPackageName());
    }

    public boolean isSearchPage() {
        return findByResId("com.taobao.taobao:id/fl_searchchoice_frame", sinShape).exists() || findByResId("com.taobao.taobao:id/searchchoice_text", sinShape).exists();
    }

    protected boolean isSearchResultPage() {
        return findByResId("com.taobao.taobao:id/search_header_container", 2).exists() || findByResId("com.taobao.taobao:id/auc_maininfo_ext", 2).exists();
    }

    protected boolean isShopAllItemPage() {
        return findByResId("com.taobao.taobao:id/shop_search_result_category_ll", 2).exists();
    }

    public boolean isShopHomePage() {
        if (findByResId("com.taobao.taobao:id/shop_search_result_search_bar", sinShape).exists()) {
            return true;
        }
        UiObject findByResId = findByResId("com.taobao.taobao:id/action_bar_title", 2);
        if (!findByResId.exists()) {
            return false;
        }
        try {
            String text = findByResId.getText();
            return "淘宝店铺".equals(text) || "天猫店铺".equals(text);
        } catch (UiObjectNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }

    protected boolean isTBLoginPage() {
        return hasResId("com.taobao.taobao:id/accountCompleteTextView", sinShape) || hasResId("com.taobao.taobao:id/loginButton", sinShape);
    }

    public boolean isTaobaoMainPage() {
        return hasResId("com.taobao.taobao:id/scan_code_icon", 2);
    }

    public boolean isTaokoulingFrame() {
        return findByResId("com.taobao.taobao:id/tp_d_content", sinShape).exists() || findByResId("com.taobao.taobao:id/tp_d_include", sinShape).exists() || findByResId("com.taobao.taobao:id/tp_d_head", sinShape).exists() || findByResId("com.taobao.taobao:id/contacts_clipwatcher_access", sinShape).exists();
    }

    public String makeTag(int i) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i2 = 0; i2 <= i; i2 += sinShape) {
            stringBuilder.append("--");
        }
        return stringBuilder.toString();
    }

    public void openMyTaobao() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        b.b(" start to enter into my taobao...", new Object[0]);
        a.h();
        c.e();
    }

    public v parsePageLoginName(UiDevice uiDevice) throws UiObjectNotFoundException {
        UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true).instance(0));
        if (!uiScrollable.exists()) {
            return new v(true, "");
        }
        uiScrollable.scrollBackward();
        UiObject child = uiScrollable.getChild(new UiSelector().instance(sinShape));
        if (!child.exists()) {
            return new v(true, "");
        }
        UiObject child2 = child.getChild(new UiSelector().className(TextView.class));
        System.out.println("<:>>>>>child2");
        debugUiObject(child2);
        return !child2.exists() ? new v(true, "") : new v(true, child2.getText());
    }

    public void pressBack(int i) {
        for (int i2 = 0; i2 < i; i2 += sinShape) {
            this.device.pressBack();
            c.b();
        }
    }

    public void recursiveTree(UiObject uiObject, int i) throws UiObjectNotFoundException {
        for (int i2 = 0; i2 < 10; i2 += sinShape) {
            System.out.println("<" + i2 + "> parent :" + uiObject + " with name :" + uiObject.getClassName());
            UiObject child = uiObject.getChild(new UiSelector().instance(i2));
            if (child.exists()) {
                String makeTag = makeTag(i);
                System.out.println(makeTag + "index<" + i2 + "> :");
                System.out.println(makeTag + child.getClassName() + ":desc " + child.getContentDescription() + "<<" + child);
                System.out.println(makeTag + child.getText() + ":" + child.getBounds() + "-" + child.getChildCount());
                child.getText();
                if (child.getChildCount() > 0) {
                    recursiveTree(child, i + sinShape);
                }
            }
        }
    }

    public void setAccParams(AccountBean accountBean) {
        this.accParams = accountBean;
    }

    public void setMissionId(long j) {
        this.missionId = j;
    }

    protected void simpleDragScroll(boolean z) {
        simpleDragScroll(z, 3);
    }

    protected void simpleDragScroll(boolean z, int i) {
        ensureForwardPoint();
        int i2 = rand.nextInt(10) % 5 > 0 ? sinShape : 0;
        Point[] pointArr = z ? this.forwardPoints : this.backwardPoints;
        Point point = pointArr[0];
        Point point2 = pointArr[pointArr.length - 1];
        if (isScrollTest) {
            c.a(this.device, z);
        } else if (i2 != 0) {
            c.a(this.device, point, point2, ovalShape1);
        } else {
            this.device.drag(point.x, point.y, point2.x, point2.y, i);
        }
        c.c();
    }

    protected void simpleDragScrollWithRect(Rect rect, boolean z) {
        int height = rect.height();
        int width = rect.width();
        int nextInt = rand.nextInt(width / ovalShape1) + 30;
        int nextInt2 = ((width / ovalShape1) + nextInt) + rand.nextInt(width / ovalShape1);
        int nextInt3 = (((height * 7) / ovalShape2) + rect.top) - rand.nextInt(((height * 30) / 800) + (height / ovalShape2));
        int nextInt4 = rand.nextInt(10) + 10;
        Point point = new Point(nextInt, ((height / ovalShape2) + rect.top) + rand.nextInt((height / ovalShape2) + ((height * 10) / 800)));
        Point point2 = new Point(nextInt2, nextInt3);
        b.b(" p1[" + point + "] p2[" + point2 + "] for isforward :" + z, new Object[0]);
        UiDevice uiDevice = this.device;
        Point point3 = z ? point2 : point;
        if (!z) {
            point = point2;
        }
        c.b(uiDevice, point3, point, nextInt4);
        c.c();
        checkSavePhotoMask();
    }

    public void testTaobao() {
        if (!isTaobaoMainPage()) {
        }
    }

    protected void tmMoveSwipe() {
    }

    public void weitaoPageItem() throws UiObjectNotFoundException, com.sutuijingling.result.c {
        checkLocationMock();
        UiObject findWeitaoView = findWeitaoView();
        if (findWeitaoView == null || !findWeitaoView.exists()) {
            c.f();
            findWeitaoView = findWeitaoView();
        }
        if (findWeitaoView == null || !findWeitaoView.exists()) {
            throw new com.sutuijingling.result.c(HttpStatus.SC_NOT_FOUND, "微淘页面进入失败!");
        }
        int i = findWeitaoView.getBounds().top;
        i += 30;
        int i2 = (findWeitaoView.getBounds().right + findWeitaoView.getBounds().left) / ovalShape1;
        if (i2 > 80) {
            i2 -= 30;
        }
        c.a(this.device, i2, i);
        c.f();
    }

    public void writeIfCanBackup(boolean z) {
        try {
            File file = new File(canBackUpPath);
            if (!file.exists()) {
                file.createNewFile();
                a.b(" chmod 777 " + canBackUpPath);
            }
            CharSequence valueOf = String.valueOf(z);
            b.b(" write content :" + valueOf + " to file :" + file, new Object[0]);
            org.apache.commons.io.b.a(file, valueOf);
            file.setReadable(true);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
